package com.bibimaya.auto.mapper.dao.mapper.processor;

import java.util.HashMap;
import java.util.Map;

public class MapperProcessorFactory {

    private final static Map<Class, MapperProcessor> mpm = new HashMap<>();

    static {
        regist(DeleteMapperProcessor.class);
        regist(GetByIdMapperProcessor.class);
        regist(GetCountMapperProcessor.class);
        regist(GetListMapperProcessor.class);
        regist(InsertListMapperProcessor.class);
        regist(InsertMapperProcessor.class);
        regist(UpdateByIdMapperProcessor.class);
        regist(UpdateByOvMapperProcessor.class);
        regist(UpdateListMapperProcessor.class);
    }

    private final static void regist(Class<? extends MapperProcessor> c) {
        try {
            MapperProcessor processor = c.newInstance();
            mpm.put(processor.getMapperInterface(), processor);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public final static MapperProcessor getMethodProcessor(Class c){
        return mpm.get(c);
    }

}
